package com.lancoo.answer.util.paperUtils;

import com.lancoo.answer.model.bean.Child;
import com.lancoo.answer.model.bean.Item;

import java.util.List;

/**
 * Created by pengmi on 2021/12/24 14:35
 * Description:判断小题对错工具
 */
public class ChildRightOrWrongJudgeUtils {

    /**
     * 获取小题作答结果状态 0-做错，1-做对，2-待评阅
     * @param child 小题
     * @return state
     */
    public static int judgeChildAnswerState(Child child){
        List<Item> itemList = child.getItemList();
        float rate=0;
        for (Item item:itemList){
            if(item.getEvalScore()<0){
                return 2;
            }
            rate+=item.getScoreRate();
        }
        boolean isWrong=rate/child.getItemList().size()<0.6;
        return isWrong?0:1;
    }




    /**
     * 获取答题点答结果状态 0-做错，1-做对，2-待评阅
     * @param item 答题点
     * @return state
     */
    public static int judateItemAnwerState(Item item){
        if(item.getEvalScore()<0){
            return 2;
        }
        boolean isWrong=item.getScoreRate()<0.6;
        return isWrong?0:1;
    }



}
